package Simulator;

import gui.MapGUI;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * The application's GUI.
 */

public class GUI extends JFrame implements Runnable
{

	private static final long refresh_time = 100;
	private static final long serialVersionUID = 1L;
	
	MapGUI mapGUI;
    public GUI() 
    {
    	this(new MapGUI());
    }
    
    public GUI(JPanel p)
    {
    	add(p);
        this.setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //setSize(1024,768);
        setSize(1024, 730);
        setLocationRelativeTo(null);
        setTitle("Ambulance Manager - City map");		
        setResizable(false);
        setVisible(true);
    }

    public GUI(MapGUI jPanel) 
    {
    	this.mapGUI = jPanel;
    	add(jPanel);
        this.setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //setSize(1024,768);
        setSize(1024, 730);
        setLocationRelativeTo(null);
        setTitle("Ambulance Manager - City map");		
        setResizable(false);
        setVisible(true);

	}

	@Override
	public void run() {
		try {
			while (true) {
				this.mapGUI.repaint();
				Thread.sleep(refresh_time);
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
    

}